package com.muyu.system.service.impl;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.system.domain.DanmoUserFlagship;
import com.muyu.system.mapper.DanmoUserFlagshipMapper;
import com.muyu.system.service.IDanmoUserFlagshipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 旗舰店关注Service业务层处理
 *
 * @author kunzong
 * @date 2024-12-24
 */
@Service
public class DanmoUserFlagshipServiceImpl implements IDanmoUserFlagshipService {
    @Autowired
    private DanmoUserFlagshipMapper danmoUserFlagshipMapper;

    /**
     * 查询旗舰店关注
     *
     * @param id 旗舰店关注主键
     * @return 旗舰店关注
     */
    @Override
    public DanmoUserFlagship selectDanmoUserFlagshipById(Long id) {
        return danmoUserFlagshipMapper.selectDanmoUserFlagshipById(id);
    }

    /**
     * 查询旗舰店关注列表
     *
     * @param danmoUserFlagship 旗舰店关注
     * @return 旗舰店关注
     */
    @Override
    public List<DanmoUserFlagship> selectDanmoUserFlagshipList(DanmoUserFlagship danmoUserFlagship) {
        return danmoUserFlagshipMapper.selectDanmoUserFlagshipList(danmoUserFlagship);
    }

    /**
     * 新增旗舰店关注
     *
     * @param danmoUserFlagship 旗舰店关注
     * @return 结果
     */
    @Override
    public Result insertDanmoUserFlagship(DanmoUserFlagship danmoUserFlagship) {
        DanmoUserFlagship danmoUserFlagship1 = danmoUserFlagshipMapper.selectDanmoUserFlagshipByFlagshipIdAndUserId(danmoUserFlagship);
        if (danmoUserFlagship1 != null) {
            return Result.success(1, "已关注");
        }
        danmoUserFlagship.setCreateTime(DateUtils.getNowDate());
        danmoUserFlagshipMapper.insertDanmoUserFlagship(danmoUserFlagship);
        return Result.success(1, "关注成功");
    }

    /**
     * 修改旗舰店关注
     *
     * @param danmoUserFlagship 旗舰店关注
     * @return 结果
     */
    @Override
    public int updateDanmoUserFlagship(DanmoUserFlagship danmoUserFlagship) {
        return danmoUserFlagshipMapper.updateDanmoUserFlagship(danmoUserFlagship);
    }

    /**
     * 批量删除旗舰店关注
     *
     * @param ids 需要删除的旗舰店关注主键
     * @return 结果
     */
    @Override
    public int deleteDanmoUserFlagshipByIds(Long[] ids) {
        return danmoUserFlagshipMapper.deleteDanmoUserFlagshipByIds(ids);
    }

    /**
     * 删除旗舰店关注信息
     *
     * @param id 旗舰店关注主键
     * @return 结果
     */
    @Override
    public int deleteDanmoUserFlagshipById(Long id) {
        return danmoUserFlagshipMapper.deleteDanmoUserFlagshipById(id);
    }
}
